% function run_experiments()

setup;

expDir = 'data';

%% modelnet experiments (w/ upright assumption)
get_imdb('modelnet40v1', ...
  'func', @(s) setup_imdb_modelnet(s,'useUprightAssumption',true), ...
  'rebuild', true);
% phase 1 -- regular cnn
cnn_shape('modelnet40v1', ...
  'expDir', fullfile(expDir,'modelnet40v1'), ...
  'numFetchThreads', 12, ...
  'pad', 32, ...
  'border', 32, ...
  'multiview', false, ...
  'batchSize', 60, ...
  'gpus', [1], ...
  'maxIterPerEpoch', Inf, ...
  'numEpochs', [15 10 15], ...
  'learningRate', [0.05*ones(1,10) 0.01*ones(1,20) 0.001*ones(1,5) 0.0001*ones(1,5)] ...
);  
% phase 2 -- mvcnn
cnn_shape('modelnet40v1', ...
  'expDir', fullfile(expDir,'modelnet40v1_mv'), ...
  'numFetchThreads', 12, ...
  'pad', 32, ...
  'border', 32, ...
  'baseModel', fullfile(expDir,'modelnet40v1','net-deployed.mat'), ...
  'multiview', true, ...
  'viewpoolPos', 'relu6', ...
  'batchSize', 5, ...
  'gpus', [1], ...
  'maxIterPerEpoch', Inf, ...
  'numEpochs', [0 15 15], ...
  'learningRate', [0.005*ones(1,5) 0.001*ones(1,5) 0.0001*ones(1,10) 0.00001*ones(1,10)] ...
);  

%% shapenet experiments (w/ upright assumption)
get_imdb('shapenet55v1', ...
  'func', @(s) setup_imdb_shapenet(s,'nViews',12,'useSubclass',false), ...
  'rebuild', true);
% phase 1 -- regular cnn
cnn_shape('shapenet55v1', ...
  'expDir', fullfile(expDir,'shapenet55v1'), ...
  'numFetchThreads', 12, ...
  'multiview', false, ...
  'batchSize', 84, ...
  'gpus', [1], ...
  'maxIterPerEpoch', [1000 200], ...  % limiting 1000 iters/epoch at training and 200 iters/epoch at testing
  'balancingFunction', @(v) round(mean(v)*(v/mean(v)).^0.5), ...
  'numEpochs', [15 10 15], ...
  'learningRate', [0.05*ones(1,10) 0.01*ones(1,10) 0.001*ones(1,10) 0.0005*ones(1,10)] ...
);  
% phase 2 -- mvcnn
cnn_shape('shapenet55v1', ...
  'expDir', fullfile(expDir,'shapenet55v1_mv'), ...
  'numFetchThreads', 12, ...
  'baseModel', fullfile(expDir,'shapenet55v1','net-deployed.mat'), ...
  'multiview', true, ...
  'viewpoolPos', 'relu7', ...
  'batchSize', 7, ...
  'gpus', [1], ...
  'maxIterPerEpoch', [1000 200], ...  % limiting 1000 iters/epoch at training and 200 iters/epoch at testing
  'balancingFunction', @(v) round(mean(v)*(v/mean(v)).^0.5), ...
  'numEpochs', [0 20 20], ...
  'learningRate', [0.005*ones(1,10) 0.001*ones(1,15) 0.0001*ones(1,10) 0.00005*ones(1,5)] ...
);  
